<% content_for :css do %>
  <%= stylesheet_link_tag 'tools_zhui_tian_ya_hot_posts_index' %>
<% end %>
<% content_for :javascript do %>
<script type="text/javascript" charset="utf-8">
  function show_or_hide(name) {
    $$('div#types div.mid').each( function(item) {
      item.className = 'type mid';
    });
    $('type_' + name).className = $('type_' + name).className + ' h';      
  }

  function go_to(page_num)
  {
    $('page').value = page_num;
    searching();
  }
  
  function search_by_hot_post_type_id(type_id)
  {
    $('hot_post_type_id').value = type_id;
    searching();
  }
  
  function searching()
  {
    <%= remote_function :update => 'hot_posts',
          :url => tools_zhui_tian_ya_hot_posts_url,
          :method => :get,
          :loading => 'loading()',
          :with => "Form.serialize('search_form') + '&' + Form.serialize('order_by_form')"
    %>
  }

  function searching_without_loading()
  {
    <%= remote_function :update => 'hot_posts',
          :url => tools_zhui_tian_ya_hot_posts_url,
          :method => :get,
          :with => "Form.serialize('search_form') + '&' + Form.serialize('order_by_form')"
    %>
  }
  
  function loading() 
  {
    <%= large_loading('all',:width => '705px', :height => '500px') %>
  }
</script>
<% end %>  
<div id="zhui_tian_ya_index">  
  <div id="types">    
    <div  class='type head_corner'>      
      <%= image_tag 'tools/zhui_tian_ya/type_head.jpg'%>
    </div>
    <div id="type_all" class='type mid h'>
      <%= link_to_function "全部 <small>#{@types.current_user_zhuis_count}</small>/<b>#{@types.hot_posts_count}</b>","show_or_hide('all');search_by_hot_post_type_id('%')",:title => "共#{@types.hot_posts_count}贴，我追了其中的#{@types.current_user_zhuis_count}贴" %>
    </div>
    <% @types.each do |type|  %>
    <div id="type_<%= type.id %>" class='type mid'>
      <%= link_to_function "『#{type.name}』<small>#{type.current_user_zhuis_count}</small>/<b>#{type.hot_posts_count}</b>","show_or_hide('#{type.id}');search_by_hot_post_type_id('#{type.id}')",:title => "共#{type.hot_posts_count}贴，我追了其中的#{type.current_user_zhuis_count}贴" %>
    </div>
    <% end %>
    <div class='type foot_corner'></div>
  </div>
  <div id='hot_posts' class='corner'>
    <%= render :file => 'tools/zhui_tian_ya_hot_posts/index.js' %>
  </div>
</div>
<% form_tag 'javascript:void(0);', :id => 'search_form'  do %>
  <%= hidden_field_tag :hot_post_type_id %>
  <%= hidden_field_tag :page %>
<% end %>